define(function(require,exports,module){
	require('enlarge');
	var ADD_TO_CAR = require('module/home/addition/addtocar.js');
	exports.init = function(){
		detail_img_style();//点击大图下面的小图，
		use_enlarge();//放大镜的效果
		click_add_plus();//数量加减,以及按钮样式
	}	
	exports.operate = function(){
		// 购物车模块被单独分在一个文件中
		ADD_TO_CAR.add_to_car();
	}
	exports.win_resize = function(){

	}

	function detail_img_style(){
		$(".detail_img div img").live('mouseenter',function(){
			$(this).parent().find("img").css("border","1px solid #ddd");
			var img_src = $(this).attr("src");
			$("#big_img img").attr("src",img_src);
			$(this).css("border","1px solid #FF7634");
		});
	}

	function use_enlarge(){
	   $("#big_img").enlarge({
	    // 鼠标遮罩层样式
	    shadecolor: "#FFD24D",
	    shadeborder: "#FF8000",
	    shadeopacity: 0.5,
	    cursor: "move",

	    // 大图外层样式
	    layerwidth: 400,
	    layerheight: 300,
	    layerborder: "#DDD",
	    fade: true,

	    // 大图尺寸
	    largewidth: 1280,
	    largeheight: 960
	    });		
	}

	function click_add_plus(){
		var input_obj = $("input[name='goods_num']");
		//初始的样式
		var num_ = input_obj.val();
		if(num_ <= 1){
			$(".num_plus").css("color","#999");
			
		}
		if(num_ >= 99){
			$(".num_add").css("color","#999");
			
		}	
		//点击的样式
		$(".num_plus").live("click",function(){
			var num = input_obj.val();
			if(num <= 1){
				$(this).css("color","#999");
				return;
			}else{
				$(".num_add").css("color","#333");
			}

			input_obj.val(num-1);
		});

		$(".num_add").live("click",function(){
			var num = input_obj.val();
			if(num >= 99){
				$(this).css("color","#999");
				return;
			}else{
				$(".num_plus").css("color","#333");
			}
			input_obj.val(parseInt(num)+1);
		});	
		//失去焦点的样式
		input_obj.live("blur",function(){
			var num = input_obj.val();
			if(num <= 1){
				$(".num_plus").css("color","#999");
				return;
			}else{
				$(".num_plus").css("color","#333");
			}
			if(num >= 99){
				$(".num_add").css("color","#999");
				return;
			}else{
				$(".num_add").css("color","#333");
			}		
		});
	}
});